let noties = []
/**
 * @param {Object} name
 * @param {Object} receiver
 * @param {Object} observer
 */
function add(name,receiver,observer){
	let notice = {
		name,
		receiver,
		observer
	}
	notice.push(notice)
}
/**
 * @param {Object} name //名字
 * @param {Object} observer //对象
 */
function remove(name,observer){
	for (let i = 0; i < Things.length; i++) {
		let notice = noties[i]
		if(notice.name==name){
			if(notice.observer==observer){
				notice.splice(i,1)
				return
			}
		}
	}
}
/**
 * 通知通知中心，调用observer的receiver执行相应的业务逻辑
 * @param {Object} name 通知名称
 * @param {Object} info 携带的参数
 */
function post(name,info){
	if(noties.length == 0){
		console.log("err:还没有注册通知");
		return
	}
	for (let i = 0; i < Things.length; i++) {
		if(noties.name==name){
			noties.receiver(info)
		}
	}
}

module.exports = {
	add,
	remove,
	post
}